<?php

namespace app\admin\model;

use think\Db;
use think\Model;

class Materiallist extends Model
{
    protected $table = "eb_special_task";
    public function MateriallistAdd($data){
        Db::startTrans();
        $return  = false;
        try {
            $res = Db::table($this->table)->insertGetId($data);
            Db::commit();
            if ($res){
                $return = true;
            }
        }catch (\Exception $e){
            Db::rollback();
        }
        return $return;
    }

    public function getOne($id){
        $res = Db::table($this->table)->where(['id'=>$id])->find();
        return $res;
    }
    public function getInfo($id){
        $res = Db::table($this->table)->where(['id'=>$id])->find();
        return $res;
    }


    public function Materiallistupdate($where,$data){
        Db::startTrans();
        $return  = false;
        try {
            $res = Db::table($this->table)->where($where)->update($data);
            Db::commit();
            if ($res){
                $return = true;
            }
        }catch (\Exception $e){
            Db::rollback();
        }
        return $return;
    }

    public function Infoeditupdate($where,$data){
        Db::startTrans();
        $return  = false;
        try {
            $res = Db::table($this->table)->where($where)->update($data);
            Db::commit();
            if ($res){
                $return = true;
            }
        }catch (\Exception $e){
            Db::rollback();
        }
        return $return;
    }

}
